<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
   <meta http-equiv="Content-Language"    content="en">
   <meta http-equiv="Content-Script-Type" content="text/javascript">
   <meta http-equiv="Content-Type"        content="text/html;charset=UTF-8">

   <title>..::[ Ajile Directives ]::..</title>

   <meta name="Description" content="Directives API :: Ajile - Advanced JavaScript Importing &amp; Loading Extension">
   <meta name="Keywords"    content="Ajile,AJILE,JavaScript inject,JavaScript include,JavaScript Namespace,JavaScript Namespacing,Javascript Import,JavaScript On-Demand,JavaScript Package,JavaScript Packaging,Unobtrusive JavaScript,namespace,package,import,include,use,require,ajax,JSPackaging,JSLoad,JSPackage,JSImport">
   <meta name="copyright"   content="Copyright &copy; 2003-2012 Michael Lee, http://ajile.net/">

   <link type="image/ico" rel="icon"          href="http://ajile.sourceforge.net/favicon.ico">
   <link type="image/ico" rel="shortcut icon" href="http://ajile.sourceforge.net/favicon.ico">
   <link type="text/css"  rel="stylesheet"    href="../iskitz-content.css" title="iSkitz Content">
</head>
<body>
<h1><a name="Index">Ajile Directives</a></h1><br>
Ajile provides five directives for working with JavaScript modules: Import,
ImportAs, Load, Namespace, and Include. Each is explained and detailed in the
following sections.<br>

<ul>
   <li><a href="#Import">Import</a>
   <li><a href="#ImportAs">ImportAs</a>
   <li><a href="#Include">Include</a>
   <li><a href="#Load">Load</a>
   <li><a href="#Namespace">Namespace</a>
</ul>
<br>Back to <a href="../Ajile-Help.htm">Documentation</a>
<pre>
<br><hr><br>
<a name="Import">Import:</a>
   The Import directive is used to dynamically load an external JavaScript
   module and make it accessible via its shortened name. A module's shortened
   name is the portion following the last "." in its fully-qualified name.
   
   If a module, system variable, object or function with the exact shortened
   name already exists. The newly imported module will only be accessible via
   its fully-qualified name. In this situation the <a href="#ImportAs">ImportAs</a> directive should be
   used to import the module using an alias.
   
   NOTE: The browser will not process the imported module until the currently
   executing module or HTML script block is completely processed or executed.
   Until that time, none of the variables or functions in the imported module
   will be accessible. Use <a href="Functions.htm#Ajile.AddImportListener">Ajile.AddImportListener()</a> to be notified when the
   imported script is ready for use.

Syntax:
   <code>Import   ( moduleName [, location] [, namingStyle] [, container] )</code>

Parameters:
   moduleName  - The fully-qualified name of the module or namespace to be imported. 

   location    - Optional. The url or file path at which the specified module
                 can be located. When not specified the location parameter
                 defaults to the namespace's location or the Ajile module's
                 location if the namespace has not been created.

   namingStyle - Optional. The naming style used by the specified module. The
                 namingStyle parameter can be any quoted notation character
                 i.e. ".", "/", "-", etc.

   container   - Optional. The object within which the imported module will be
                 accessible. When not specified, the container parameter
                 defaults to the browser's window object.
   
Examples:
   The following statement:
   
      <code>Import ("com.iskitz.ajile.examples.ImportExample");</code>
      
   Imports the ImportExample module from the com.iskitz.ajile.examples namespace
   using default settings for its location, namingStyle and container. If the
   com.iskitz.ajile.examples namespace was not already defined, the ImportExample
   module would be loaded using the com.iskitz.ajile namespace location and
   naming style.

See:
   - <a href="#ImportAs">Import</a>
   - <a href="#Include">Include</a>
   - <a href="Functions.htm#Ajile.AddImportListener">Ajile.AddImportListener()</a>
   - <a href="#Load">Load</a>
   - <a href="#Namespace">Namespace</a>


Back to <a href="#Index">Top</a> or <a href="../Ajile-Help.htm">Documentation</a>

<br><hr><br>
<a name="ImportAs">ImportAs:</a>
   The ImportAs directive is used to dynamically load an external JavaScript
   module and make it accessible via the specified alias name. This directive
   enhances the Import directive by removing the limitation of shortened name
   accessiblity.
   
   As with the Import directive, if the specified alias exactly matches the name
   of an existing module, system variable, object or function the newly imported
   module will only be accessible via its fully-qualified name. In this
   situation a different alias name should be used.
   
   NOTE: The browser will not process the imported module until the currently
   executing module or HTML script block is completely processed or executed.
   Until that time, none of the variables or functions in the imported module
   will be accessible. Use <a href="Functions.htm#Ajile.AddImportListener">Ajile.AddImportListener()</a> to be notified when the
   imported script is ready for use.
   
Syntax:
   <code>ImportAs ( aliasName, moduleName [, location] [, namingStyle] [, container] )</code>

Parameters:
   aliasName   - The alias by which the imported module will be accessible. 

   moduleName  - The fully-qualified name of the module or namespace to be imported. 

   location    - Optional. The url or file path at which the specified module
                 can be located. When not specified the location parameter
                 defaults to the namespace's location or the Ajile module's
                 location if the namespace has not been created.

   namingStyle - Optional. The naming style used by the specified module. The
                 namingStyle parameter can be any quoted notation character
                 i.e. ".", "/", "-", etc.

   container   - Optional. The object within which the imported module will be
                 accessible. When not specified, the container parameter
                 defaults to the browser's window object.

Examples:
   The following statement:
   
      <code>ImportAs ("MyExample", "com.iskitz.ajile.examples.ImportExample");</code>
      
   Imports the ImportExample module from the com.iskitz.ajile.examples namespace
   using the MyExample alias name. The module is imported using default settings
   for its location, namingStyle and container. If the com.iskitz.ajile.examples
   namespace was not already defined, the ImportExample module would be loaded
   using the com.iskitz.ajile namespace location and naming style.

See:
   - <a href="#Import">Import</a>
   - <a href="#Include">Include</a>
   - <a href="Functions.htm#Ajile.AddImportListener">Ajile.AddImportListener()</a>
   - <a href="#Load">Load</a>
   - <a href="#Namespace">Namespace</a>


Back to <a href="#Index">Top</a> or <a href="../Ajile-Help.htm">Documentation</a>

<br><hr><br>
<a name="Include">Include:</a>
   The Include directive is used to dynamically load an external JavaScript
   module and make it accessible via its fully-qualified name. A module's
   fully-qualified name is comprised of its full namespace and its short name.
   
   If a module, object or function with the exact fully-qualified name already
   exists, the module being included won't be accessible via its
   fully-qualified name. In this situation the <a href="#ImportAs">ImportAs</a> directive should be used to
   include the module using an alias.
   
   NOTE: The browser will not process the included module until the currently
   executing module or HTML script block is completely processed or executed.
   Until that time, none of the variables or functions in the included module
   will be accessible. Use <a href="Functions.htm#Ajile.AddImportListener">Ajile.AddImportListener()</a> to be notified when the
   included script is ready for use.

Syntax:
   <code>Include   ( moduleName [, location] [, namingStyle] [, container] )</code>

Parameters:
   moduleName  - The fully-qualified name of the module or namespace to be included. 

   location    - Optional. The url or file path at which the specified module
                 can be located. When not specified the location parameter
                 defaults to the namespace's location or the Ajile module's
                 location if the namespace has not been created.

   namingStyle - Optional. The naming style used by the specified module. The
                 namingStyle parameter can be any quoted notation character
                 i.e. ".", "/", "-", etc.

   container   - Optional. The object within which the included module will be
                 accessible. When not specified, the container parameter
                 defaults to the browser's window object.
   
Examples:
   The following statement:
   
      <code>Include ("com.iskitz.ajile.examples.IncludeExample");</code>
      
   Includes the IncludeExample module from the com.iskitz.ajile.examples namespace
   using default settings for its location, namingStyle and container. If the
   com.iskitz.ajile.examples namespace was not already defined, the IncludeExample
   module would be loaded using the com.iskitz.ajile namespace location and
   naming style.

See:
   - <a href="#Import">Import</a>
   - <a href="#ImportAs">ImportAs</a>
   - <a href="Functions.htm#Ajile.AddImportListener">Ajile.AddImportListener()</a>
   - <a href="#Load">Load</a>
   - <a href="#Namespace">Namespace</a>


Back to <a href="#Index">Top</a> or <a href="../Ajile-Help.htm">Documentation</a>

<br><hr><br>
<a name="Load">Load:</a>
   The Load directive is used to dynamically load an external JavaScript
   module from the specified location.
   
   NOTE: The browser will not process the loaded module until the currently
   executing module or HTML script block is completely processed or executed.
   Until that time, none of the variables or functions in the loaded module
   will be accessible.
   

Syntax:
   <code>Load  ( location [, container] [,code] [, defer] [, title] [, type] [, language] )</code>

Parameters:
   location    - The url or file path where the external JavaScript module can
                 be located.

   container   - Optional. The object within which the loaded script will be
                 accessible. When not specified, the container parameter
                 defaults to the browser's window object.

   code        - Optional. JavaScript code to be executed.

   defer       - Optional. A boolean to indicate whether the browser should
                 delay processing of the loaded script until it' host page has
                 completed loading. true indicates

   title       - Optional. A string to be associated with the loaded script. The
                 default value is blank.

   type        - Optional. A string representing the content-type of script to
                 be loaded (i.e. "text/javascript"). This parameter defaults to
                 "text/javascript" when unspecified.

   language    - Optional. A string representing the loaded script's language
                 (i.e. "JavaScript"). This parameter defaults to "JavaScript"
                 when unspecified.

Examples:
   The following statement:
   
      <code>Load ("http://ajile.net/examples/Examples.js");</code>
      
   Loads the Examples module from the /examples/ directory on the
   ajile.net server using default values for its container, type, defer,
   language, and title settings.

See:
   - <a href="#Import">Import</a>
   - <a href="#ImportAs">ImportAs</a>
   - <a href="#Include">Include</a>


Back to <a href="#Index">Top</a> or <a href="../Ajile-Help.htm">Documentation</a>

<br><hr><br>
<a name="Namespace">Namespace:</a>
   The Namespace directive is used to create a unique JavaScript namespace if
   none matching the specified name exists.
   
   JavaScript modules that wish to be uniquely identifiable should use the
   Namespace directive to declare their namespace membership. A module cannot be
   defined as a member of a namespace that has not been created via the
   Namespace directive. This is the reason why the Namespace directive must be
   used prior to defining namespace member modules.
   
   NOTE: Namespaces are immediately available after using the Namespace
   directive.

Syntax:
   <code>Namespace   (name [, location] [, namingStyle] [, container] )</code>

Parameters:
   name        - A string representing the fully-qualified namespace to be
                 created.

   location    - Optional. The url or file path to be associated with the new
                 namespace. When not specified the location parameter defaults
                 to the parent namespace's location or the Ajile module's
                 location if the parent namespace has not been created.

   namingStyle - Optional. The naming style used by the specified module. The
                 namingStyle parameter can be any quoted notation character
                 i.e. ".", "/", "-", etc.

   container   - Optional. The object within which the namespace will be
                 accessible. When not specified, the container parameter
                 defaults to the browser's window object.

Examples:
   The following statements:
   <code>
      Namespace ("com.iskitz.ajile.examples");
      
      com.iskitz.ajile.examples.MyExample = function()
      {
         this.message = "This is my example!";
      };
   </code>   
   Create the com.iskitz.ajile.examples namespace and define the MyExample
   module. The namespace is created using default values for its location,
   namingStyle, and container settings.

See:
   - <a href="#Import">Import</a>
   - <a href="#ImportAs">ImportAs</a>


Back to <a href="#Index">Top</a> or <a href="../Ajile-Help.htm">Documentation</a>

<br><hr><br>
</pre>
<br /><a id="lnkSFLogo" href="http://sourceforge.net/projects/ajile/"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=149163&type=1" border="0" alt="SourceForge.net Logo" title="Ajile @ SourceForge" /></a>
</body>
</html>